"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2025/6/16
"""
import base64

data = 'yes'
print(data)
print(type(data))  # str

# 进行base64编码
data = data.encode('utf-8')
data = base64.b64encode(data)
data = data.decode()
print(data)

# 进行base64解码
data = data.encode('utf-8')
data = base64.b64decode(data)
data = data.decode()
print(data)

s = "eW91eQg3"
# 填充为4的倍数
s += ("=" * (4 - len(s) % 4))
print("填充后", s)
ret = base64.b64decode(s).decode()
print(ret)  # 必须是4的倍数  否则无法还原
